package com.wnxy.jdk8;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.*;
import java.util.stream.Stream;

public class App3 {
    public static void main(String[] args) {
    }


    private static void t1() {
        // 创建流：串行流，单线程执行
        List<String> list = new ArrayList<>();
        Stream<String> stream = list.stream();

        // 并行流：多线程执行
        Stream<String> parallel = list.stream().parallel();
        Stream<String> stringStream = list.parallelStream();

        // 创建数组流
        String[] array = new String[]{"aa"};
        Stream<String> stream1 = Arrays.stream(array);

        Stream<String> array1 = Stream.of(array);

        // 无限流：用于遍历
        Stream<Integer> limit = Stream.iterate(10, num->num+2).limit(5);
        //limit.forEach(System.out::println);

        Stream<String> limit1 = Stream.generate(() -> "hello").limit(3);
        limit1.forEach(System.out::println);

    }
}